/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.dao.hibernate;

import com.click.app.dao.PantDetailDao;
import com.click.app.model.Employee;
import com.click.app.model.PantDetail;
import com.click.app.model.ProcessDressmaker;
import java.util.Date;
import java.util.List;

/**
 *
 * @author ronald
 */
public class PantDetailDaoHibernate extends GenericDaoHibernate<PantDetail, Long> implements PantDetailDao  {

    public PantDetailDaoHibernate(){
        super(PantDetail.class);
    }

    public List<PantDetail> findByProcessDressmaker(ProcessDressmaker processDressmaker) {
        return getHibernateTemplate().find("from PantDetail where processDressmaker=?", processDressmaker);
    }

    public List<PantDetail> findByEmployee(Employee employee) {
        return getHibernateTemplate().find("from PantDetail where processDressmaker.employee=? AND currentAmount>0", employee);
    }

    public List<PantDetail> findByEmployeePeriod(Employee employee, Date initDate, Date endDate) {
        Object[] objects = {employee, initDate, endDate};
        return getHibernateTemplate().find("from PantDetail where processDressmaker.employee=? and processDressmaker.endDate Between ? And ? order by processDressmaker.endDate", objects);
    }
}
